<template>
    <div class="cancelAccouunt topStyley">
        <!-- 这个组件 没用了  -->
        <el-card class="box-card">
            <div slot="headerss" class="clearfix text_fl">
                <!-- <span>公共服务类   -----销户申请</span> -->
                <el-button class="btn_close" type="text" @click="handleClose">关闭</el-button>
            </div>
            <div>
                <div>
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="账户类别:" class="text_fl">
                                    <el-select
                                        v-model="searchForm.accttype"
                                        placeholder="请选择账户类别"
                                        @change="changeCardList"
                                    >
                                        <el-option
                                            v-for="item in AccountionTYPE_INFO"
                                            :label="item.label"
                                            :key="item.label"
                                            :value="item.code"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="卡号:" class="text_fl">
                                    <el-select v-model="searchForm.cardno" placeholder="请选择卡号">
                                        <el-option
                                            v-for="item in cardList"
                                            :label="item.CARDNBR"
                                            :value="item.CARDNBR"
                                            :key="item.CARDNBR"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <div v-show="step1Page">
                    <h1>销户初审：</h1>
                    <el-divider></el-divider>
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="当前账面余额：" class="text_fl">
                                        <span
                                            class="el-form-item-span"
                                        >{{pageFormValue.bookBalance }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="授权未请款金额：" class="text_fl">
                                        <span
                                            class="el-form-item-span"
                                        >{{pageFormValue.authNoClaim }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="应收未收违约金：" class="text_fl">
                                        <span
                                            class="el-form-item-span"
                                        >{{pageFormValue.uncollectedPenalty }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="content table_eltabs">
                            <el-table
                                :data="accountCardList"
                                style="width: 100%"
                                border
                                height="200px"
                                class="table_head heard-bg setbottomborder"
                                :stripe="true"
                            >
                                <el-table-column label="卡号" min-width="60">
                                    <template slot-scope="scope">{{ scope.row.cardNo }}</template>
                                </el-table-column>
                                <el-table-column label="是否有未结清分期" min-width="20">
                                    <template slot-scope="scope">{{ scope.row.isHaveInstallment }}</template>
                                </el-table-column>
                                <el-table-column label="是否为制卡日" min-width="20">
                                    <template slot-scope="scope">{{ scope.row.isMakeCardDay }}</template>
                                </el-table-column>
                            </el-table>
                        </div>
                        <div class="text_center">
                            <el-button type="primary" size="small" @click="step1Submit">初审</el-button>
                        </div>
                    </el-form>
                </div>
                <div v-show="step2Page">
                    <h1>销户挽留：</h1>
                    <el-divider></el-divider>

                    <div class="cardY">
                        <div class="tab-header">
                            <div class="bodyTitles">销户原因</div>
                        </div>
                        <el-row>
                            <el-checkbox-group
                                name="closeReasonList"
                                v-model="formData.closeReason"
                            >
                                <el-col :span="6" v-for="item in closeReasonList" :key="item.label">
                                    <el-checkbox
                                        :label="item.label"
                                        :key="item.code"
                                        @change="handelCheckboxClosecode($event,item.code)"
                                    ></el-checkbox>
                                </el-col>
                            </el-checkbox-group>
                        </el-row>
                    </div>
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <div class="text_center">
                            <el-button type="primary" size="small" @click="step2SubmitSuccess">挽留成功</el-button>
                            <el-button type="primary" size="small" @click="step2SubmitFail">挽留失败</el-button>
                        </div>
                    </el-form>
                </div>
                <div v-show="step3Page">
                    <h1>销户确认：</h1>
                    <el-divider></el-divider>

                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="积分值：" class="text_fl">
                                        <span
                                            class="el-form-item-span"
                                        >{{pageFormValue.integralValue }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="content table_eltabs">
                            <el-table
                                :data="accountCardList"
                                style="width: 100%"
                                border
                                height="200px"
                                class="table_head heard-bg setbottomborder"
                                :stripe="true"
                            >
                                <el-table-column label="卡号" min-width="60">
                                    <template slot-scope="scope">{{ scope.row.cardNo }}</template>
                                </el-table-column>
                                <el-table-column label="是否绑定ETC" min-width="20">
                                    <template slot-scope="scope">{{ scope.row.isBindingETC }}</template>
                                </el-table-column>
                                <el-table-column label="电子现金余额" min-width="20">
                                    <template slot-scope="scope">{{ scope.row.ecashBalance }}</template>
                                </el-table-column>
                            </el-table>
                        </div>
                        <h3>必讲话术：</h3>
                        <div class="content table_eltabs">
                            <el-table
                                :data="speechCraftList"
                                style="width: 100%"
                                border
                                height="200px"
                                class="table_head heard-bg setbottomborder"
                                :stripe="true"
                            >
                                <el-table-column label="编号" min-width="20">
                                    <template slot-scope="scope">{{ scope.row.sortNum }}</template>
                                </el-table-column>
                                <el-table-column label="内容" min-width="80">
                                    <template slot-scope="scope">{{ scope.row.content }}</template>
                                </el-table-column>
                            </el-table>
                        </div>
                        <div class="text_center">
                            <el-button type="primary" size="small" @click="handelSure">确认</el-button>
                        </div>
                    </el-form>
                    <el-dialog
                        v-drag
                        title="销户申请"
                        :visible.sync="centerDialogVisible"
                        width="500px"
                        :append-to-body="true"
                        top="30vh"
                        :close-on-click-modal="false"
                        center
                    >
                        <p>
                            账户类别：
                            <span>{{this.searchForm.accttypeStr}}</span>
                        </p>
                        <p>
                            卡号：
                            <span>{{this.searchForm.cardno}}</span>
                        </p>

                        <p class="text_center padding_top15">
                            <span style="color:#3a8ee6; ">您确认要销户吗？</span>
                        </p>
                        <span slot="footer" class="dialog-footer">
                            <el-button
                                size="small"
                                icon="el-icon-circle-close"
                                @click="centerDialogVisible = false"
                            >取 消</el-button>
                            <el-button
                                type="primary"
                                size="small"
                                @click="submitForm"
                                icon="el-icon-circle-check"
                            >确定</el-button>
                        </span>
                    </el-dialog>
                </div>
            </div>
        </el-card>
    </div>
</template>

<script>
import { mapGetters } from 'vuex';
import moment from 'moment';
import {
    trimString, closePage, getDictMappingValue, itoStr, updateDeal3004, updateDeal3601, setETCCardInfo, getNewCardAccount3001,
} from '@/utils/Common';
import { isEmptyObject } from '@/utils/Object';

export default {
    name: 'cancelAccouunt',
    data() {
        return {
            formData: {
                CATEGORY: '', // 账户类别
                CARDNO: '', // 卡号
                IDTYPE: '', // //证件种类
                CUSTID: '', // 证件号码
                AUTOFLAG: '0', // 溢缴款自动结清申请
                CLSFLAG: '1', // 销户标志
                BANKFLAG: '0', // 销户自动结清转账行标志
                executionDate: '2021-06-20',
                closeReason: [], // 销户原因选中选项
                closeReasonIds: [], // 销户原因选中选项Ids
            },
            rules: {
                BEGDATE: [{ required: true, message: '请选择菜单类型' }],
            },
            // defaultParams: this.$store.getters.defaultParams || '', // 更新报文
            cancelAccouuntInfo: {}, // 销卡成功返回回来的数据
            isCATEGORY: '',
            centerDialogVisible: false,
            PRODUCT_value: '',
            productId: '',
            step1Page: true,//1-初审
            step2Page: false,//2-挽留
            step3Page: false,//3-确认
            searchForm: { // 账户类型、卡号双选字段
                accttype: '', //账户类型，编号
                cardno: '', //账号
                accttypeStr: '', // 账户类型显示值
            },
            cardList: [], //卡列表
            closeReasonList: [], // 查询全部-销卡原因列表
            speechCraftList: [], //话术列表
            pageFormValue: { //页面表单值，随账户选择变动
                bookBalance: '0', // 当前账面余额 3001-40
                authNoClaim: '0', // 授权未请款金额 3001-16
                uncollectedPenalty: '0', // 应收未收违约金 3001-84
                isHaveInstallment: '否', // 是否有未结清分期   -  卡级别-获取3077遍历
                isMakeCardDay: '否', // 是否为制卡日  -  卡级别-获取制卡日判断
                isBindingETC: '否', // 是否绑定ETC  -  卡级别-接口获取
                ecashBalance: '0', // 电子现金余额  -   卡级别-获取-3096
                integralValue: '0', // 积分值 3001-102
            },
            accountCardList: [], //账户下卡（是否绑定ETC，电子现金余额）列表
            pageAccountInfo: {}, // 下拉选变更，账户信息（废弃），改为newCardAccountInfo_3001
            RtnindFlag: '',//3077-翻页标志
            NEXTDAY_3077: '20000101',//3077-翻页交易日期
            NEXTMPNO_3077: '0',//3077-翻页分期付款序号
            InstallmentInfo_3077: [],//3077分期付款交易明细查询
            RTNIND_value: '', // 3134翻页标志
            ETCSTATUS_value: false,//3134ETC签约关系查询交易接口
            pageLoading: true,//3134
            newCardAccountInfo_3001: '',//3001new-卡账户信息 每次切换账户更换信息
            step1SubmitCheck: true,//初审检验是否通过，金额类字段只要有金额＞0或者是否类字段结果为“是”的，只要满足其一，初审则不通过
        };
    },
    computed: {
        ...mapGetters([
            'defaultParams',
            'cardInfo_3004',
            'cardAccountInfo_3001',
            'cardList_3601',
            'pinFlag',
            'AccountionTYPE_INFO',
            'userInfo',
        ]),
    },
    // mapState({
    //     defaultParams: state => state.common.defaultParams, // 接口默认参数
    //     cardInfo_3004: state => state.common.cardInfo_3004,
    //     cardAccountInfo_3001: state => state.common.cardAccountInfo_3001, // 卡账户信息
    //     cardList_3601: state => state.common.cardList_3601,
    //     defaultpinFlag: state => state.common.pinFlag,
    //     AccountionTYPE_INFO: state => state.common.AccountionTYPE_INFO, //账户类别列表
    //     userInfo: state => state.user.userInfo,
    // }),
    async mounted() {
        this.newCardAccountInfo_3001 = this.cardAccountInfo_3001;
        this.formData.CATEGORY = this.cardInfo_3004.CATEGORY;
        this.formData.CARDNO = this.cardInfo_3004.CARDNO;
        this.formData.IDTYPE = this.cardInfo_3004.KEYTYPE;
        this.formData.CUSTID = this.cardInfo_3004.CUSTID;
        console.info(this.AccountionTYPE_INFO, "AccountionTYPE_INFO");
        await this.getDictValue();
        // 初始化双选下拉
        this.searchForm.accttype = this.cardInfo_3004.CATEGORY + '';

        await this.changeCardList(this.cardInfo_3004.CATEGORY + '');

    },
    methods: {
        //页面进入限制条件，呆账核销（W）、核销清户（WQ）、停计息费（X1）限制无法打开销户申请页面
        pageEntryLimit() {
            let accountStat = this.cardAccountInfo_3001.CARDSTAT;
            console.info("=============pageEntryLimit,当前账户状态：" + accountStat);
            if (accountStat == "W" || accountStat == "WQ" || accountStat == "X1") {
                this.$alert(
                    "当前账户状态异常，账户状态：" + accountStat + "，无法进入销户页面！",
                    '销户提示',
                    { customClass: 'warning', type: 'warning', showClose: false },
                ).then(() => {
                    closePage(this.$route, this, 1);
                });
            };

        },
        // 账户类型 字典取值
        async getDictValue() {
            this.isCATEGORY = await getDictMappingValue('CATE', this.formData.CATEGORY, this);
            this.PRODUCT_value = await getDictMappingValue('PRODUCT', this.cardInfo_3004.PRODUCT, this);
            this.closeReasonList = await this.getDictDetails('XH_REASON'); // 查询销户原因列表
            // 查询加载话术
            var checkParam = {
                'code': 'closeaccount_apply', //话术类型编号
            };
            this.$post.queryServiceClass.speechcraftlistByCode(checkParam).then((res) => {
                console.log(res);
                if (res.status === 200) { // http通讯成功
                    if (res.data.status == 0) { // 业务请求成功
                        this.speechCraftList = res.data.content;

                    } else {
                        const ErrorMessage = `错误码：${res.data.status} ` + `错误信息：${res.data.msg}`;
                        this.$alert(ErrorMessage, '请求异常:', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });
        },
        // 账号选择变更事件
        async changeCardList(val) {
            console.log("============changeCardList-val：" + val);
            // 更新账户类型显示值
            this.searchForm.accttypeStr = await getDictMappingValue('CATE', val, this);

            let hasDefault = false; //是否包含默认卡
            this.cardList = [];
            this.cardList_3601.forEach((item) => {
                if (item.CATEGORY + '' === val) {
                    this.cardList.push(item);
                    if (item.CARDNBR === this.cardInfo_3004.CARDNO) {
                        hasDefault = true;
                    }
                }
            });

            // 包含默认卡，卡号显示默认卡，不包含，显示cardList里第一张卡号
            if (hasDefault) {
                this.searchForm.cardno = this.cardInfo_3004.CARDNO;
            } else {
                this.searchForm.cardno = this.cardList[0].CARDNBR;
            }

            // 初始化页面元素值
            await this.changePageFormValue();
        },
        //账户变动，页面值变化
        async changePageFormValue() {
            this.step1SubmitCheck = true; // 初审是否通过判断,初始化成功
            // 更新 newCardAccountInfo_3001
            await getNewCardAccount3001(this.searchForm.cardno, this);
            /**************账户级别***/
            console.info("==============changePageFormValue-账户级别-this.newCardAccountInfo_3001", this.newCardAccountInfo_3001);
            this.pageFormValue.bookBalance = this.newCardAccountInfo_3001.BALNCE; // 当前账面余额
            this.pageFormValue.authNoClaim = this.newCardAccountInfo_3001.AUTHAMT; // 授权未请款金额
            this.pageFormValue.uncollectedPenalty = this.newCardAccountInfo_3001.PENCHG; // 应收未收违约金
            if (this.pageFormValue.bookBalance > 0 || this.pageFormValue.authNoClaim > 0 || this.pageFormValue.uncollectedPenalty > 0) {//初审是否通过判断
                this.step1SubmitCheck = false;
            }

            this.pageFormValue.integralValue = this.newCardAccountInfo_3001.POINT1; // 积分值
            /**************卡级别***/
            console.info("==============changePageFormValue-卡级别-this.cardList", this.cardList);
            this.accountCardList = [];

            for (let index = 0; index < this.cardList.length; index++) {
                const cardTemp = this.cardList[index];
                // let cardNo = cardTemp.CARDNBR;
                let cardOne = await this.changePageCardLevelInfo(cardTemp);
                this.accountCardList.push(cardOne);
            }
        },
        //账户变动，页面卡片级值变化，多卡账户，循环遍历
        async changePageCardLevelInfo(cardTemp) {
            let cardNo = cardTemp.CARDNBR;
            let makeCardDate = cardTemp.OPENDATE; //开卡日期 eg."20200403"
            console.info("==============changePageCardLevelInfo-cardNo：" + cardNo);
            let isMakeCardDay = '否'; // 是否为制卡日
            let todayStr = moment(new Date()).format('YYYYMMDD');
            if (todayStr == makeCardDate) {
                this.step1SubmitCheck = false;
                isMakeCardDay = '是';
            }

            //3096查询电子现金余额，查询前出入参初始化
            let ecashBalance = '0'; // 电子现金余额
            await this.getICCardInfo3096(cardNo);
            ecashBalance = this.pageFormValue.ecashBalance;
            //3077查询是否有未结清分期，查询前出入参初始化
            let isHaveInstallment = '否'; // 是否有未结清分期
            this.RtnindFlag = '';
            this.NEXTDAY_3077 = '20000101';
            this.NEXTMPNO_3077 = '0';
            this.InstallmentInfo_3077 = [];
            await this.getFQFK3077(cardNo);
            if (this.InstallmentInfo_3077.length != 0) {
                this.step1SubmitCheck = false;
                isHaveInstallment = '是';
            }
            //是否绑定ETC，查询前出入参初始化
            // 3134ETC签约关系查询交易接口
            let isBindingETC = '否'; // 是否绑定ETC
            this.RTNIND_value = '';
            this.ETCSTATUS_value = false;
            this.pageLoading = true;
            await setETCCardInfo(cardNo, this);
            if (this.ETCSTATUS_value) {
                isBindingETC = '是';
            }


            let cardOne = {
                cardNo: cardNo,
                isHaveInstallment: isHaveInstallment,
                isMakeCardDay: isMakeCardDay,
                isBindingETC: isBindingETC,
                ecashBalance: ecashBalance
            };
            return cardOne;
        },

        //
        handelSure() {
            this.centerDialogVisible = true;
        },
        // 4011信用卡销户 销卡交易
        submitForm() {
            const defaultParam = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParam.body.appHead.tranCode = '4011';// 修改交易号
            defaultParam.body.appBody = {
                PINFLAG: this.pinFlag,
                PIN: '',
                CARDNBR: this.formData.CARDNO,
                IDTYPE: this.formData.IDTYPE,// 证件种类
                CUSTID: this.formData.CUSTID,// 证件号码，
                CLSFLAG: this.formData.CLSFLAG,// //销户标志
                AUTOFLAG: this.formData.AUTOFLAG, // //溢缴款自动结清申请
                CLSFLAG: this.formData.CLSFLAG, // 销户标志
                BANKFLAG: this.formData.BANKFLAG, // 销户自动结清转账行标志
            };
            this.$post.common.transPort(defaultParam).then((res) => {
                console.log(res);
                if (res.status === 200) { // 请求成功
                    const cardlossofs = JSON.parse(res.data.jsonRes);
                    console.log(cardlossofs, '4011信用卡销户');
                    if (cardlossofs.sysHead.rspCd == '000000') { // 交易成功
                        this.cancelAccouuntInfo = cardlossofs.body.appBody;
                        // this.isShowSuccess=true;
                        updateDeal3004(this.cardInfo_3004.CARDNO, this);
                        updateDeal3601(this.cardInfo_3004.CARDNO, this.cardInfo_3004.KEYTYPE, this.cardInfo_3004.CUSTID, this);
                        const successMessage = `姓名:${(`${this.cancelAccouuntInfo.NAME}`).trim()} 卡号：${this.cancelAccouuntInfo.CARDNBR} 销户成功！`;
                        const ts = `${cardlossofs.sysHead.busiName}提示`;
                        this.$alert(successMessage, ts, {
                            customClass: 'success', type: 'success',
                            callback: (action) => {
                                this.handleClose();
                            },
                        });
                    } else {
                        const ErrorMessage = `错误码：${cardlossofs.sysHead.rspCd} ` + `错误信息：${cardlossofs.sysHead.rspMsg}`;
                        this.$alert(ErrorMessage, cardlossofs.sysHead.busiName, '提示', {
                            customClass: 'error', type: 'error',
                        });
                    }
                    this.centerDialogVisible = false;
                }
            });
        },
        // 关闭页面
        handleClose() {
            closePage(this.$route, this, 1);
        },
        // 跳转到销户申请初审页面
        pageJump() {
            this.$router.push({
                path: '/operationDeals/ClosingAccountFirstInstance',
            });
        },

        // 查字典-取销户原因列表
        async getDictDetails(val) {
            let params = {};
            let accountName;
            params = {
                dictValue: val,
                pageNum: 1,
                pageSize: 1000,
            };
            await this.$post.common.getBaseDataList(params).then((res) => {
                console.log(res, '=============getDictDetails-res，val:' + val);
                if (res.status === 200) {
                    accountName = res.data.content;
                } else {
                    this.$message.error(res.data.msg);
                }
            });
            return accountName;
        },
        // 销卡原因选中事件
        handelCheckboxClosecode(event, code) {
            if (event) {
                this.formData.closeReasonIds.push(code);
            } else {
                this.formData.closeReasonIds.forEach((item, i) => {
                    if (item === code) {
                        this.formData.closeReasonIds.splice(i, 1);
                    }
                });
            }
        },

        // 销户记录入库
        closeAccountSaveDB() {
            // 拼接获取销户原因
            let closecodestr = ',';	// 销卡原因：代码1-原因描述1,代码2-原因描述2...
            const closecodeVal = this.formData.closeReason;
            const closecodeIdVal = this.formData.closeReasonIds;
            for (let i = 0; i < closecodeVal.length; i++) {
                closecodestr = `${closecodestr + closecodeVal[i]}-${closecodeIdVal[i]},`;
            }
            console.log('===========closeAccountSaveDB销户原因：', closecodestr);
            console.log('===========closeAccountSaveDB-this.userInfo', this.userInfo);

            // 参数：cardNo-卡号，opt-操作人，closeReason-销户原因
            var checkParam = {
                'cardNo': this.searchForm.cardno,
                'xhFlag': '1', //是否可销户标志，1-是；0-否
                'closeReason': closecodestr, //销户原因
                'createUser': this.userInfo.userAccount,
                'busiType': '1', //业务类型，1-销户，2-销卡
            };

            this.$post.queryServiceClass.closeAcctRecord(checkParam).then((res) => {
                console.log(res);
                if (res.status === 200) { // http通讯成功
                    if (res.data.status === 0) { // 业务请求成功
                        const successMessage = `卡号${this.searchForm.cardno} 销户记录保存成功！`;
                        const ts = '销户记录保存提示';
                        this.$alert(successMessage, ts, {
                            customClass: 'success', type: 'success',
                        });
                    } else {
                        const ErrorMessage = `错误码：${res.data.status} ` + `错误信息：${res.data.msg}`;
                        this.$alert(ErrorMessage, '销户记录保存失败', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });

        },

        // 3096IC卡交易明细查询
        async getICCardInfo3096(cardNo) {
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            let params = {
                OPTION: 'A',
                CARDNBR: cardNo, // 卡号
                TRANTYPE: 'A', // 分期类型
                OPERCODE: '0',//操作代码，0-全部返回，1-可提前还款的分期交易，2-可撤销的分期交易
                PINFLAG: this.pinFlag, // 是否检查密码标志 0-不检查
                STDATE: moment().subtract(1, 'year').format('YYYYMMDD'), // 开始日期 默认为当前日期往前一个月, // 起始日期 YYYYMMDD
                ENDDTE: moment().format('YYYYMMDD'), // 终止日期
                RTNIND: '', // 翻页标志 首次传空， 翻页传1
                CENDT: '', // 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的交易传输时间
                TRCNBR: '', // 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的系统跟踪号
                ACQNO: '',// 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的代理机构标识码
                FORNO: '',// 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的发送机构标识码
                TXNDATE: '',// 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的交易日期
                OPDATE: '',// 首次查询时送空， 下翻页查询时上送上次查询结果的最后一条记录返回的登记日期
                OPTIME: '',// 首次查询时送空， 下翻页查询时上
            };
            defaultParams.body.appBody = Object.assign(this.defaultParams.body.appBody, params);
            defaultParams.body.appHead.tranCode = '3096';// 修改交易号
            console.log('=============getICCardInfo3096-defaultParams:', defaultParams);
            await this.$post.common.transPort(defaultParams).then((res) => {
                console.log('=============getICCardInfo3096-res:', res);
                if (res.status === 200) { // 请求成功
                    const cardlossofs = JSON.parse(res.data.jsonRes);
                    if (cardlossofs.sysHead.rspCd == '000000') { // 交易成功
                        // 取芯片卡可用余额
                        this.pageFormValue.ecashBalance = cardlossofs.body.appBody.BALANCE || '0';

                    } else {
                        // const ErrorMessage = `错误码：${cardlossofs.sysHead.rspCd} ` + `错误信息：${cardlossofs.sysHead.rspMsg}`;
                        // this.$alert(ErrorMessage, cardlossofs.sysHead.busiName, { customClass: 'error', type: 'error' });
                        this.pageFormValue.ecashBalance = '0';
                    }
                }
            });
        },

        // 3077分期付款交易明细查询，用于判断是否有未结清分期
        async getFQFK3077(cardNo) {
            const appBody = {
                CARDNBR: cardNo, // 卡号
                // 空或Z：全部  A：灵活分期 C：信用计划分期 B：余额转移 H：银联POS分期 L：大额分期 M：邮购分期  P：自行POS分期 S：深圳银联POS分期 Y：余额/账单分期 D：自动分期
                MPTYPE: '', // 分期付款类型
                OPERCODE: 1, // 操作代码  0全部返回  1可提前还款的分期交易    2可撤销的分期交易
                OPT: 1, // 查询方式 1-用卡号查询 2-用证件号码查询
                //CATE: this.accountType, // 账户类别 查询方式为2时，必填
                PINFLAG: this.pinFlag, // 是否检查密码标志
                BEGDAY: "20000101", // 起始日期
                ENDDAY: moment(new Date()).format('YYYYMMDD'), // 结束日期 两个月 内的
                RTNIND: this.RtnindFlag,// 翻页标志 首次传空， 翻页传1
                NEXTDAY: this.NEXTDAY_3077,// 首次查询时送查询起始日期， 下翻页查询时上送上次查询结果的最后一条记录返回的分期付款交易日期
                NEXTMPNO: this.NEXTMPNO_3077,// 首次查询时送起始序号，默认为0 下翻页查询时上送上次查询结果的最后一条记录返回的交易序号
            };
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParams.body.appHead.tranCode = '3077';
            defaultParams.body.appBody = appBody;
            // 3077交易
            this.$post.common.transPort(defaultParams).then((res) => {
                if (res.status === 200) {
                    const result = JSON.parse(res.data.jsonRes);
                    if (result.sysHead.rspCd === '000000') {
                        this.InstallmentInfo_3077.push(...result.body.appBody.dataList);

                        if (result.body.appBody.RTNIND === '1') {
                            this.NEXTDAY_3077 = result.body.appBody.dataList[result.body.appBody.dataList.length - 1].BEGYM;
                            this.NEXTMPNO_3077 = result.body.appBody.dataList[result.body.appBody.dataList.length - 1].MPNO;
                            // 修改翻页标志 
                            this.RtnindFlag = result.body.appBody.RTNIND
                            this.getFQFK3077();
                        } else {
                            console.log('this.InstallmentInfo_3077', this.InstallmentInfo_3077);
                        }
                    }
                }
            });
        },

        // 初审提交
        step1Submit() {
            //金额类字段只要有金额＞0或者是否类字段结果为“是”的，只要满足其一，初审则不通过，并显示原因；初审通过则进入销户挽留页面
            if (!this.step1SubmitCheck) {
                this.$alert(
                    "存在金额类字段只要有金额＞0或者是否类字段结果为“是”，初审不通过！",
                    '销户初审提示',
                    { customClass: 'warning', type: 'warning', showClose: false },
                ).then(() => {
                    // closePage(this.$route, this, 1);
                });
                return;
            } else {//切换挽留页
                this.step1Page = false;
                this.step2Page = true;
            }

        },

        // 挽留-成功
        step2SubmitSuccess() {
            this.$alert(
                "挽留成功，取消销户！",
                '销户挽留提示',
                { customClass: 'success', type: 'success', showClose: false },
            ).then(() => {
                // closePage(this.$route, this, 1);
            });
            return;
        },
        // 挽留-失败
        step2SubmitFail() {
            //销户记录入库
            this.closeAccountSaveDB();
            //切换确认页
            this.step2Page = false;
            this.step3Page = true;
        },

    },
};
</script>

<style lang='scss' >
.cancelAccouunt {
    /* .el-form-item-span {
        background-color: #f5f7fa;
        border-color: #e4e7ed;
        color: #606266;
        cursor: not-allowed;
        width: 250px;
        min-width: 200px;
        height: 35px;
        line-height: 35px;
        display: inline-block;
        background-image: none;
        border-radius: 4px;
        border: 1px solid #dcdfe6;
        box-sizing: border-box;
        padding: 0 15px;
    } */
    .el-card__header {
        padding: 8px !important;
    }

    .el-card.is-always-shadow {
        -webkit-box-shadow: none;
        box-shadow: none;
    }
    .el-card {
        border: none;
    }
}
</style>
